<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增轮播位置')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-carouselSeat-add">
            <div class="form-group">    
                <label class="col-sm-3 control-label">轮播位置描述：</label>
                <div class="col-sm-8">
                    <input name="seatName" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">序号：</label>
                <div class="col-sm-8">
                    <input name="sortNum" class="form-control" type="text" onkeyup="value=value.replace(/[^\d{1,}\.\d{1,}|\d{1,}]/g,'')">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <input name="remarks" class="form-control" type="text">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script type="text/javascript">
        var prefix = ctx + "carouselSeat/carouselSeat"
        $("#form-carouselSeat-add").validate({
            onkeyup: false,
            rules:{
                sortNum:{
                    remote: {
                        url: prefix + "/checkNumUnique",
                        type: "post",
                        dataType: "json",
                        data: {
                            "sortNum": function() {
                                return $("input[name='sortNum']").val();
                            },
                        },
                        dataFilter: function(data, type) {
                            return $.validate.unique(data);
                        }
                    }
                }
            },
            messages: {
                "sortNum": {
                    remote: "序号重复"
                }
            },
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-carouselSeat-add').serialize());
            }
        }
    </script>
</body>
</html>